
import 'package:flutter/material.dart';

import '../pages/components/Home.dart';
import '../pages/components/Contact.dart';
import '../pages/components/Dynamic.dart';
import '../pages/components/Profile.dart';
import '../pages/common/ContactsInfo.dart';
import '../pages/components/RouterPage/contacts/AddContacts.dart';
final routes = {
  '/':(context) => Home(),
  '/contact':(context) => Contact(), 
  '/dynamic':(context) => Dynamic(),
  '/profile':(context) => Profile(),
  '/contacts_info':(context) => ContactsInfo(),
  '/add_contacts':(context) => AddContacts(),
};



//固定写法(命名路由传参数)
var OnGenerateRoute = (RouteSettings settings) {
  //统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if(pageContentBuilder != null) {
    if(settings.arguments != null) {
      final Route route = MaterialPageRoute(
        builder: (context) => pageContentBuilder(context, arguments:settings.arguments)
      );
      return route;  
    }else{
      final Route route = MaterialPageRoute(
        builder: (context) => pageContentBuilder(context)
      );
      return route;
    }
  }
};